import java.util.Scanner;
import java.util.Collection;
public class jinzhi {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a;
        int jinzhi;
        a=in.nextInt();
        jinzhi=in.nextInt();
        int b;
        String str="";
        if(a==0) System.out.print("0");
        while(a>0){
            b=a%jinzhi;
            a=a/jinzhi;
            if(b>9)
                str=(char)('A'+(b-10))+str;
            else
                str=b+str;
        }
        System.out.println(str);
    }
}
